﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles{

    <style>
    </style>
}

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="organize-form" style="padding: 15px 0 0 0;">

            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">原始密码:</label>
                <div class="layui-input-block">
                    <input type="password" name="OriginalPwd" placeholder="请输入原始密码" class="layui-input"  lay-verify="required" required="">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">新密码:</label>
                <div class="layui-input-block">
                    <input type="password" name="NewPwd" placeholder="请输入新密码" class="layui-input"  lay-verify="required|password" required="">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">确认密码:</label>
                <div class="layui-input-block">
                    <input type="password" name="AgainPwd" placeholder="请再次输入新密码" class="layui-input"  lay-verify="required|equalTo" required="">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="pear-btn pear-btn-primary pear-btn-md" lay-submit lay-filter="userpwd-submit" id="userpwd-submit">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
@section scripts{

    <script type="text/javascript">
            layui.use(['lscom', 'form'], function () {
                var $ = layui.$;
                var lscom = layui.lscom;
                var form = layui.form;
                //自定义验证规则
                form.verify({

                    password: function (value) {
                        if (!/(?=.{8,16})(?=.*[a-z])(?=.*[A-Z])(?=.*\d).*/.test(value)) {
                            return '密码包含大小写字母和数字，并且长度在6-12之间';
                        }
                    },
                    equalTo: function (value) {
                        if (value != $("input[name='NewPwd']").val()) {
                            return '新密码、确认密码不一致';
                        }
                    }
                });
                form.on('submit(userpwd-submit)', function (data) {

                    var field = data.field;

                    var waitIndex = parent.layer.load(2);
                    lscom.ajax({
                        url: "/Systems/User/ModifyPassWord",
                        data: JSON.stringify(field),
                        lsHandleError: false
                    }).done(function (data) {
                        if (data.code == 0) {
                            lscom.notify.success(data.message);
                        }
                    }).fail(function (message) {
                        lscom.notify.error(message);
                    }).always(function () {
                        parent.layer.close(waitIndex);
                    });

                    return false;
                });

            
            });
    </script>
   
}


